<!--
 * @Date: 2024-12-23 18:35:22
 * @LastEditors: Lcx l1556461835@163.com
 * @LastEditTime: 2024-12-27 13:11:11
 * @FilePath: \webprocessdesign\pages\simulation\components\BasicForm.vue
 * @Description: 
-->
<template>
  <div>
    <el-form ref="basicFormRef" :model="formInfo" :inline="inline" :label-position="labelPos" :label-width="labelWidth">
      <el-form-item v-for="(item, index) in formList" :key="index" :label="item.label" :prop="item.prop"  :style="{width: item.width ? item.width : ''}">
        <template v-if="item.type == 'input'" >
          <el-input v-model.trim="formInfo[item.prop]"></el-input>
        </template>
        <template v-if="item.type == 'numberInput'" >
          <el-input v-model.trim="formInfo[item.prop]" @input="(v)=>(formInfo[item.prop] = v.replace(/[^\d.]/g,''))"></el-input>
        </template>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    inline: {
      type: Boolean,
      default: false
    },
    formInfo: {
      type: Object,
      default: () => {}
    },
    formList: {
      type: Array,
      default: () => []
    },
    labelPos: {
      type: String,
      default: "top"
    },
    labelWidth: {
      type: [String, Number],
      default: "auto"
    }
  },
  data() {
    return {};
  },
  methods: {
    resetForm() {
      this.$refs.basicFormRef.resetFields();
    }
  }
};
</script>

<style>
</style>
